package com.dotflat.survey.dto;

import com.dotflat.rest.domain.AreableObjectBase;
import com.dotflat.survey.domain.SurveySheet;
import com.dotflat.survey.domain.SurveySheetItem;
import com.starinside.wp.foundation.exception.BusinessException;
import com.starinside.wp.foundation.model.ErrorCode;
import com.tuo51.foudation.utils.CopyUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("问卷列表条目")
public class SurveySheetDTO extends AreableObjectBase {

    @ApiModelProperty("标题")
    private String title;

    @ApiModelProperty("有效期")
    private Date validTo = new Date();

    @ApiModelProperty("幼儿园名称")
    private String areaName;

    @ApiModelProperty("老师名称")
    private String staffName;

    public static SurveySheetDTO of(SurveySheet sheet){
        if (sheet == null){
            throw new BusinessException(ErrorCode.PARAM_CAN_NOT_BLANK, "对象为空");
        }

        SurveySheetDTO ret = new SurveySheetDTO();

        CopyUtils.copyProperties(sheet, ret);

        return ret;
    }

}
